package org.activequant.util.store;

import java.io.Serializable;

import org.activequant.dao.IStoreDao;
import org.activequant.store.IStoreService;

/**
 * Implements private store utilizing dao.
 * <p>
 * DaoStore implements IStoreService.<br/>
 * Holds the following associated variable:
 * <ul>
 * <li>storeDao(IStoreDao)</li>
 * </ul>
 * <b>History:</b><br>
 *  - [07.01.2008] Created (Erik Nijkamp)<br>
 *
 *  @author Erik Nijkamp
 */
public class DaoStore implements IStoreService {
	/**
	 * private final IStoreDao storeDao;
	 */
	private final IStoreDao storeDao;
	/**
	 * constructs a DaoStore(implements IStoreService) using the given storeDao(IStoreDao) to set its associated
	 * storeDao(IStoreDao)
	 * @param storeDao
	 */
	public DaoStore(IStoreDao storeDao) {
		this.storeDao = storeDao;
	}
	/**
	 * invokes <code>storeDao.find(name)</code> on the associated storeDao(IStoreDao) using the given name(String) and returns a Serializable
	 */
	public Serializable load(String name) throws Exception {
		return storeDao.find(name);
	}
	/**
	 * invokes <code>storeDao.update(name, object)</code> on the associated storeDao(IStoreDao) using the given name(String) and object(Serializable)
	 */
	public void save(String name, Serializable object) throws Exception {
		storeDao.update(name, object);
	}
}
